<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="me.linczh.bank.bean.LogBean" %>
<%@ page import="me.linczh.bank.bean.enums.Operation" %>
<%@ page import="me.linczh.bank.bean.enums.Department" %>
<%@ page import="me.linczh.bank.bean.EmployeeBean" %>
<%@ page import="me.linczh.bank.bean.enums.Position" %>
<%
EmployeeBean user = null;
if (request.getSession().getAttribute("user") != null) {
	user = (EmployeeBean)request.getSession().getAttribute("user");
}
%>

<p>
	<%=request.getAttribute("contentpage") %>
</p>
<% if (request.getAttribute("logs") != null) {
			List<LogBean> logs = (List<LogBean>)request.getAttribute("logs");
			for (LogBean l : logs) { %>
<p>
	[<%=l.getOperation() %>]&nbsp;
	<%=l.getEmployeename() %>(<%=l.getEmployee() %>):
	<%=l.getAccount() %>&nbsp;
	<%=l.getOperation() %>&nbsp;by&nbsp;
	<%=l.getUsername() %>(<%=l.getIdentity() %>)&nbsp;at&nbsp;
	<%=l.getTime() %>
</p>
<%		}
	 } else { %>
<form action="employee.report.action" method="POST" role="form">
	<fieldset>
		<legend>查询日志</legend>
		<p>
			<label class="radio-inline">
				<input type="radio" name="datetype" value="0"> 日报
			</label>
			<label class="radio-inline">
				<input type="radio" name="datetype" value="1"> 月报
			</label>
			<label class="radio-inline">
				<input type="radio" name="datetype" value="2"> 季度报
			</label>
			<label class="radio-inline">
				<input type="radio" name="datetype" value="3"> 年报
			</label>
		</p>
		<div class="form-group">
	    <label for="date">日期</label>
	    <input type="date" class="form-control" id="date" name="date" placeholder="日期">
	  </div>
		<div class="form-group">
	    <label for="month">月份</label>
	    <input type="month" class="form-control" id="month" name="month" placeholder="月份">
	  </div>
		<div class="form-group">
	    <label for="quarter">季度</label>
		  <select class="form-control" id="quarter" name="quarter">
			  <option value="0">第一季度</option>
			  <option value="1">第二季度</option>
			  <option value="2">第三季度</option>
			  <option value="3">第四季度</option>
			</select>
	  </div>
		<div class="form-group">
	    <label for="year">年份</label>
	    <input type="text" class="form-control" id="year" name="year" placeholder="年份">
	  </div>
	 </fieldset>
	 <% if (user.getPosition() != Position.OPERATOR) { %>
	 <fieldset>
	  <legend>高级查询</legend>
	  <p>
			<label class="radio-inline">
				<input type="radio" name="querytype" value="0"> 雇员
			</label>
			<label class="radio-inline">
				<input type="radio" name="querytype" value="1"> 部门
			</label>
			<% if (user.getPosition() == Position.SUPERVISOR) { %>
			<label class="radio-inline">
				<input type="radio" name="querytype" value="2"> 银行
			</label>
			<% } %>
		</p>
		<div class="form-group">
	    <label for="employee">雇员</label>
	    <input type="text" class="form-control" id="employee" name="employee" placeholder="雇员ID">
	  </div>
	  <% if (user.getPosition() == Position.SUPERVISOR) { %>
		<div class="form-group">
	    <label for="department">部门</label>
	    <select class="form-control" id="department" name="department">
	    <% for (Department d : Department.values()) { %>
	    	<option value="<%=d.name() %>"><%=d.name() %></option>
	    <% } %>
	    </select>
	  </div>
	  <% } %>
	</fieldset>
	<% } %>
	<button type="submit" class="btn btn-default">查询</button>
</form>
<% } %>